package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mallcloud.mall.app.api.entity.dto.XglPartingPaymentDerateDTO;
import com.mallcloud.mall.app.api.entity.vo.XglPartingPaymentInfoVO;
import com.mallcloud.mall.app.service.AppXglParkingService;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.XglParkingRedeemSettingModel;
import com.mallcloud.mall.mall.api.entity.dto.ProXglParkingRedeemRecordReporting;
import com.mallcloud.mall.mall.service.XglParkingRedeemSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "app-星光里停车管理")
@RestController
@AllArgsConstructor
@RequestMapping("/app/xglParking")
@ConditionalOnProperty("const.park.appId")
public class AppXglParkingController {
	private final AppXglParkingService appXglParkingService;
	private final XglParkingRedeemSettingService xglParkingRedeemSettingService;

	@ApiOperation("查询在场车辆停车费")
	@GetMapping("/paymentInfo")
	public R<XglPartingPaymentInfoVO> paymentInfo(String carNumber) {
		return R.ok(appXglParkingService.getParkingPaymentInfo(carNumber));
	}

	@ApiOperation("减免金额")
	@PostMapping("/derate")
	public R<Boolean> derate(@RequestBody XglPartingPaymentDerateDTO dto) {
		return R.ok(appXglParkingService.derate(dto));
	}

	@ApiOperation("停车兑换设置列表")
	@GetMapping("/parkSettingList")
	public R<List<XglParkingRedeemSettingModel>> list(XglParkingRedeemSettingModel dto) {
		return R.ok(xglParkingRedeemSettingService.list(Wrappers.lambdaQuery(dto)));
	}

	@ApiOperation("停车兑换")
	@PostMapping("/redeem")
	public R<Boolean> redeem(@RequestBody ProXglParkingRedeemRecordReporting dto) {
		return R.ok(appXglParkingService.redeem(dto));
	}

	/**
	 * 停车兑换记录查询
	 * {@link AppPointLogController.outPage}
	 */
}
